<#include "/@inc/uiMacros.ftl">
<#include "/@inc/funcMacros.ftl">
<#include "/@inc/copyright.txt">
<#assign className = TriaGram + Prefix + LateType + "Cmd">
<#assign intfName = TriaGram + "I" + Prefix + LateType>
<#assign baseName = TriaGram + Prefix + LateType>
<#assign factoryName = TriaGram + "I" + Prefix >
<#assign IDLName = TriaGram + "IA" + Prefix >
<@pp.renameOutputFile name=className+".cpp">
</@pp.renameOutputFile>
//==============================================================================
//
// ${className}.cpp
// The command: ${className}
//
//===============================================================================
//  ${Month} ${Year}  Creation: Code generated by the CAA wizard  ${Author}
//===============================================================================

<@CALC_STATES Attributes  />

<#assign numStates = states?size >

//Local Framework
#include "${className}.h"
#include "${baseName}Dlg.h"

//${TriaGram}${AppName}Interfaces
#include "${intfName}.h"
#include "${factoryName}Factory.h"
#include "${IDLName}${LateType}.h"
#include "${IDLName}Factory.h"

//${TriaGram}UtilInterfaces
#include "${TriaGram}IUtlDlgList.h"
#include "${TriaGram}IUtlEntity.h"
#include "${TriaGram}IUtlEntityList.h"
#include "${TriaGram}UtlDlgFrame.h"

#include "${TriaGram}IUtlPartDocService.h"

//${TriaGram}${AppName}UtilsFw
#include "${TriaGram}UtlMacros.h"
#include "${TriaGram}UtlErrDisplay.h"
#include "${TriaGram}UtlErrorManager.h"
#include "${TriaGram}UtlScriptManager.h"

//ObjectSpecModeler
#include "CATISpecObject.h"

//DialogEngine
#include "CATCustomizableState.h"
#include "CATStateCancelNotification.h"

//System
#include "CATUnicodeString.h"

//MecModInterfaces
#include "CATIPrtPart.h"
#include "CATIAPart.h"
#include "CATIAFactory.h"
#include "CATIAHybridBody.h"
#include "CATMecModAutoServices.h"

<#list Attributes as attrib>
<#if (attrib.IID?length > 0) >
#include "${attrib.IID}.h"
</#if>
</#list>

//KnowledgeItf
#include "CATICkeParm.h"

//DialogEngine Framework
#include "CATDialogTransition.h"
<#if (numStates > 0 ) >
#include "CATFeatureImportAgent.h"
#include "CATDialogAgent.h"
</#if>

#include "CATCreateExternalObject.h"

CATCreateClass( ${className});
//-----------------------------------------------------------------------------
// ${className} : constructor
//-----------------------------------------------------------------------------
${className}::${className}(CATISpecObject * ipSpecFeature, int inMode):
${TriaGram}UtlPanelStateCmd("${className}", NULL, CATCommandModeExclusive, inMode, ipSpecFeature)
{
	_pPanel = NULL;
	//_MyFeature = ipSpecFeature ; Done in base class
<#list states as st>
	_pFeatureAgent${st.name}  = NULL ;
	_pDialogAgent${st.name}  = NULL ;
</#list>

<#list Attributes as attrib>
<#switch attrib.UI>
<#case "List">
<#case "BiList">
<#case "PolyList">
	_pUtlDlgFrame${attrib.name}   = NULL  ;
<#break>
</#switch>
</#list>
}

//-----------------------------------------------------------------------------
// ${className} : destructor
//-----------------------------------------------------------------------------
${className}::~${className}()
{
    ${TriaGram}_SCRIPT_RECORD( STOP ) ;
	${TriaGram}UtlRequestDel(_pPanel);

<#list states as st>
	${TriaGram}UtlRequestDel(_pFeatureAgent${st.name} ) ;
	${TriaGram}UtlRequestDel(_pDialogAgent${st.name} ) ;
</#list>
<#list Attributes as attrib>
<#switch attrib.UI>
<#case "List">
<#case "BiList">
<#case "PolyList">
	_pUtlDlgFrame${attrib.name}   = NULL  ;
<#break>
</#switch>
</#list>

}

//-----------------------------------------------------------------------------
// ${className} : BuildGraph
//-----------------------------------------------------------------------------
void ${className}::BuildGraph()
{
	HRESULT hr = E_FAIL;

    if( FAILED(CheckModel()) )
    {
        RequestDelayedDestruction();
		return;
	}

    //Create Feature if in Creation Mode
    hr = CreateFeature() ;
    if (FAILED(hr))
    {
        ${TriaGram}UtlErrDisplay::DisplayBox("${baseName}Errors", "CreationError");
        RequestDelayedDestruction();
        return;
    }

	//Create Dialog and update the panel
    BuildPanel() ;

<#if states?size == 0 >
        // This method,from CATMMUIPanelStateCommand, manages the OK, Cancel transitions
        CATDialogState * pInitalState = GetInitialPanelState("InitialState");
<#else>
	CreateStateChart() ;
 </#if>

}


void ${className}::CreateStateChart ()
{
<#if numStates == 1 >
<#assign st = states[0]>
		CATCustomizableState * p${st.name}State = GetInitialPanelState("${st.name}State");
		_pFeatureAgent${st.name} = new CATFeatureAgent("${st.name}Agent");
		 _pFeatureAgent${st.name} -> AddElementType (IID_${st.IID} );
		_pFeatureAgent${st.name} -> SetBehavior(CATDlgEngWithPSOHSO | CATDlgEngWithPrevaluation | CATDlgEngValuedFromCSO | CATDlgEngWithUndo );
		_pFeatureAgent${st.name} -> SetAgentBehavior ( MfPermanentBody  | MfLastFeatureSupport | MfRelimitedFeaturization );

		p${st.name}State->AddDialogAgent(_pFeatureAgent${st.name});

		CATDialogTransition * pTransition${st.name}  = AddTransition(p${st.name}State, p${st.name}State,
					  IsOutputSetCondition(_pFeatureAgent${st.name}),
					  Action((ActionMethod) &${className}::OnSelect${st.name}));
<#else>
// 1. Create States and Feature and Dialog Agents
<#list states as st>
		<#if st_index == 0 >
		CATCustomizableState * p${st.name}State = GetInitialPanelState("${st.name}State");
		<#else>

		CATCustomizableState * p${st.name}State = AddPanelState("${st.name}State");
		</#if>

        _pFeatureAgent${st.name} = new CATFeatureAgent("${st.name}Agent");
         _pFeatureAgent${st.name} -> AddElementType ( IID_${st.IID} );
        _pFeatureAgent${st.name} -> SetBehavior(CATDlgEngWithPSOHSO | CATDlgEngWithPrevaluation | CATDlgEngValuedFromCSO | CATDlgEngWithUndo );
    	_pFeatureAgent${st.name} -> SetAgentBehavior ( MfPermanentBody  | MfLastFeatureSupport | MfRelimitedFeaturization );

        _pDialogAgent${st.name} = new CATDialogAgent("${st.name}Agent");
        _pDialogAgent${st.name} -> AcceptOnNotify ( _pUtlDlgFrame${st.name} , _pUtlDlgFrame${st.name}->GetList(0)->GetListSelectNotification() );
</#list>

// 2. Attach Agents to states
<#list states as st>

		// Attach Agents to ${st.name}State
		p${st.name}State->AddDialogAgent(_pFeatureAgent${st.name});
		p${st.name}State->AddDialogAgent(_pDialogAgent${st.name});
		<#list states as stOther>
			<#if st_index != stOther_index >
		p${st.name}State->AddDialogAgent(_pDialogAgent${stOther.name});
		 	</#if>
		</#list>
</#list>

// 3. Add Transitions
<#list states as st>

		<#list states as stOther>
			<#assign diff = stOther_index - st_index >
			<#if diff  == 1>
		// Transition when ${st.name} is selected
		AddTransition( p${st.name}State, p${stOther.name}State,
					  IsOutputSetCondition(_pFeatureAgent${st.name}),
					  Action((ActionMethod) &${className}::OnSelect${st.name}));
		 	</#if>
			<#if st_index != stOther_index >

		// Transition when ${st.name}List is selected
		AddTransition( p${stOther.name}State, p${st.name}State,
					  IsOutputSetCondition(_pDialogAgent${st.name}),
					  Action((ActionMethod) &${className}::OnSelect${st.name}List));
		 	</#if>
		</#list>

			<#-- For last state. Create a Transition back to the first state -->
			<#if st_index == ( numStates -1 ) >
		// Transition when ${st.name} is selected - back to the first state
		AddTransition( p${st.name}State, p${states[0].name}State,
					  IsOutputSetCondition(_pFeatureAgent${st.name}),
					  Action((ActionMethod) &${className}::OnSelect${st.name}));
		 	</#if>
</#list>

 </#if>
}

<#list states as st>
CATBoolean ${className}::OnSelect${st.name}(void *)
{
	CATPathElement *pPathElement =  _pFeatureAgent${st.name}->GetValue();

	int nResult = _pUtlDlgFrame${st.name}->AddToList(pPathElement, "",  0) ;

	_pUtlDlgFrame${st.name}->Refresh() ;

    // gets ready for next acquisition
    _pFeatureAgent${st.name}->InitializeAcquisition();

    return TRUE;
}

CATBoolean ${className}::OnSelect${st.name}List(void *)
{
    // gets ready for next acquisition
    _pDialogAgent${st.name}->InitializeAcquisition();

    // Clear up selection/highlighting of other Lists.

    return TRUE;
}
</#list>


void ${className}::BuildPanel()
{
	${intfName}_var sp${LateType} = _MyFeature ;
    CATAssert(NULL_var != sp${LateType}) ;

	_pPanel = new ${baseName}Dlg();
    _pPanel->Build(sp${LateType});
    _pPanel->SetVisibility(CATDlgShow);

<#list Attributes as attrib>
<#switch attrib.UI>
<#case "List">
	CATDlgFrame *pFrame${attrib.name} = _pPanel->Get${attrib.name}Frame()   ;

    _FrameStyle${attrib.name}._IID = IID_${attrib.IID}  ;
    _FrameStyle${attrib.name}._nVisibleTextWidth = 20;
    _FrameStyle${attrib.name}._StrCatalog = "${baseName}Dlg" ;
	_FrameStyle${attrib.name}._FrameStyle = ${TriaGram}UtlDlgDefaultList ;
    _FrameStyle${attrib.name}._ListStyle[0] |= ${TriaGram}UtlDlgProcessBeforeFather ;

    <#if attrib.type == "tk_specobject">
    _FrameStyle${attrib.name}._ListStyle[0] |= ${TriaGram}UtlDlgSingleElement ;
    CATISpecObject_var  spSpec${attrib.name} ;
    sp${LateType}->Get${attrib.name}(spSpec${attrib.name} ) ;
    _pUtlDlgFrame${attrib.name} = BuildSingleElementListFrame(pFrame${attrib.name}, "UtlSelectorList${attrib.name}", _FrameStyle${attrib.name}, spSpec${attrib.name} ) ;
    <#else>
    CATLISTV(CATISpecObject_var)  list${attrib.name} ;
    sp${LateType}->Get${attrib.name}(list${attrib.name} ) ;
    _FrameStyle${attrib.name} ._pListFeatureEnt = &list${attrib.name}  ;
    _pUtlDlgFrame${attrib.name} = BuildUtlDlgFrame(pFrame${attrib.name}, "UtlSelectorList${attrib.name}", _FrameStyle${attrib.name}) ;
    </#if>
    //ClearSelect() ;

<#break>
<#case "BiList">
    // Double Row List Frame
	CATDlgFrame *pFrame${attrib.name} = _pPanel->Get${attrib.name}Frame()   ;

    CATLISTV(CATISpecObject_var)  list${attrib.name} ;
    sp${LateType}->Get${attrib.name}(list${attrib.name} ) ;

	_FrameStyle${attrib.name}._nSearchType = 2 ; // Search via CATIDescandants of Part
	_FrameStyle${attrib.name}._strIID = "${attrib.IID}"  ;
    _FrameStyle${attrib.name}._IID = IID_${attrib.IID}  ;
    _FrameStyle${attrib.name}._pListFeatureEnt = &list${attrib.name}  ;
    _FrameStyle${attrib.name}._StrCatalog = "${baseName}Dlg" ;
    _FrameStyle${attrib.name}._ListStyle[0] |= ${TriaGram}UtlDlgProcessBeforeFather ;
    _FrameStyle${attrib.name}._ListStyle[1] |= ${TriaGram}UtlDlgProcessBeforeFather ;

    _pUtlDlgFrame${attrib.name} = BuildUtlDlgFrame(pFrame${attrib.name}, "UtlSelectorList${attrib.name}", _FrameStyle${attrib.name}) ;

<#break>
<#case "PolyList">
    // Double Row List Frame
	CATDlgFrame *pFrame${attrib.name} = _pPanel->Get${attrib.name}Frame()   ;

    CATLISTV(CATISpecObject_var)  list${attrib.name} ;
    sp${LateType}->Get${attrib.name}(list${attrib.name} ) ;

	_FrameStyle${attrib.name}._nSearchType = 2 ; // Search via CATIDescandants of Part
	_FrameStyle${attrib.name}._strIID = "${attrib.IID}"  ;
    _FrameStyle${attrib.name}._IID = IID_${attrib.IID}  ;
    _FrameStyle${attrib.name}._pListFeatureEnt = &list${attrib.name}  ;
    _FrameStyle${attrib.name}._StrCatalog = "${baseName}Dlg" ;
    _FrameStyle${attrib.name}._ListStyle[0] |= ${TriaGram}UtlDlgProcessBeforeFather ;

    _FrameStyle${attrib.name}._FrameStyle = ${TriaGram}UtlDlgMultiListLeft | ${TriaGram}UtlDlgRemoveButtonLeft  | ${TriaGram}UtlDlgDefaultCtxMenu | ${TriaGram}UtlDlgReplaceButtonLeft  ;
    _FrameStyle${attrib.name}._nNumCol[0] = ${attrib.data?size} ; // Number of colums in list
    _FrameStyle${attrib.name}._PFNameFunction[0] = (${TriaGram}UtlDlgListColumnName )&${className}::${attrib.name}ColumnName ;

    _pUtlDlgFrame${attrib.name} = BuildUtlDlgFrame(pFrame${attrib.name}, "UtlSelectorList${attrib.name}", _FrameStyle${attrib.name}) ;

<#break>
</#switch>
</#list>
}


<#list Attributes as attrib>
<#switch attrib.UI>
<#case "PolyList">
int ${className}::${attrib.name}ColumnName (${TriaGram}IUtlEntity *ipEnt, int inCol, CATUnicodeString & oStrName)
{
    CATAssert(ipEnt) ;

    oStrName = "Undefined" ;

    CATISpecObject_var spSpecEnt ;
    ipEnt->GetEntitySpec(spSpecEnt) ;

    //double dPercent = 0.0 ;
	${intfName}_var sp${LateType} = spSpecEnt ;

    switch(inCol)
    {
    case 0 :
        ipEnt->BuildDisplayName(oStrName, ${TriaGram}UtlDlgPubNameAndAlias) ;
    	break;
    case 1 :
        oStrName = "Column One" ;
        //sp${LateType}->GetStartPercent(dPercent);
        break;
    case 2 :
        oStrName = "Column One" ;
        //sp${LateType}->GetEndPercent(dPercent);
        break;
    default:
        break ;
    }

   // oStrName.BuildFromNum(dPercent) ;

    return 0 ;
}

<#break>
</#switch>
</#list>

//-----------------------------------------------------------------------------
// ${className} : GiveMyPanel
//-----------------------------------------------------------------------------
CATDlgDialog* ${className}::GiveMyPanel()
{
	return _pPanel ;
}

CATBoolean ${className}::OkAction( void*  iData)
{
	HRESULT rc = E_FAIL;

    ${TriaGram}_SCRIPT_RECORD( RESUME )  ;

    rc = SetFeatureData() ;

	rc = UpdatePartNFeature(1, GetMode());

	return CATMMUIPanelStateCmd::OkAction(iData);
}

//-------------------------------------------------------------------------
// ${className} : PreviewAction()
//-------------------------------------------------------------------------
CATBoolean ${className}::PreviewAction( void*  iData)
{
	HRESULT rc = E_FAIL;

    rc = SetFeatureData() ;

	// Update the whole Part
	rc = UpdatePartNFeature(0, 1); // Update only feature, pretend its create mode even for Edit mode

	return CATMMUIPanelStateCmd::PreviewAction(iData);;
}

//-------------------------------------------------------------------------
// ${className} : CreateFeature()
//-------------------------------------------------------------------------
HRESULT ${className}::CreateFeature()
{
	HRESULT hr = S_OK ;

    // Nothing to do in Edit Mode
	if(0 == GetMode() )
        return S_OK ;

    ${TriaGram}_SCRIPT_RECORD( RESUME )  ;
	if(NULL_var == _MyFeature)
	{
        ///Get Part from the Container
        CATIAPart_var spCATIAPart = GetPart()  ;

        CATBSTR bstrName;
        CATUnicodeString strFactory("${Prefix}Factory");
        strFactory.ConvertToBSTR(&bstrName);

        CATIAFactory* pOrigFactory = NULL;
        hr = spCATIAPart->GetCustomerFactory(bstrName, pOrigFactory);

        ${IDLName}Factory_var spAutoFactory = pOrigFactory;
        if(NULL_var != spAutoFactory)
        {
			// Instaniate the Feature and insert in Geom Set
            ${IDLName}${LateType}   *piA${LateType} = NULL ;
            hr = spAutoFactory->Create${LateType}( TRUE, piA${LateType} ) ;
            _MyFeature = piA${LateType} ;
            ${TriaGram}UtlReleasePtr(piA${LateType});
        }
        else
        {
			//Create ${LateType}
			${factoryName}Factory_var spFactory = ::${TriaGram}UtlCreateContExtension( GetPart(), IID_${factoryName}Factory);
			if(!spFactory)
				return E_FAIL;

			// Instaniate the Feature and insert in Geom Set
			hr = spFactory->Create${LateType}(_MyFeature, TRUE);
			if( NULL_var == _MyFeature)
				return E_FAIL;
        }

        ${TriaGram}UtlReleasePtr(pOrigFactory) ;

        if(NULL_var == _MyFeature)
        {
			// Error Creating Feature. Make Error
			return hr ;
		}

        //Aggregate the feature in spec tree
        //Get the active hybrid body from the part and add the feature in that
        //CATIABase* pBaseOnGeomSet = NULL;
        //hr = spCATIAPart->get_InWorkObject(pBaseOnGeomSet);
        //if(NULL == pBaseOnGeomSet)
        //    return E_FAIL;

 		// If the is no geometrical set then queryinterface for CATIAHybridBody fails
        //CATIAHybridBody_var spGeomSet = pBaseOnGeomSet;
        //if(NULL_var == spGeomSet)
        //    return E_FAIL;

        // Smart Pointer to the interface is crashing !!
        //${IDLName}${LateType} *pAuto${LateType} = NULL ;
        //hr = _MyFeature->QueryInterface(IID_${IDLName}${LateType}, (void **)&pAuto${LateType} );
        //if(NULL != pAuto${LateType})
        //	hr = spGeomSet->AppendHybridShape(pAuto${LateType});
        //${TriaGram}UtlReleasePtr(pAuto${LateType}) ;
	}

	return hr;
}


//-------------------------------------------------------------------------
// ${className} : SetFeatureData()
//-------------------------------------------------------------------------
HRESULT ${className}::SetFeatureData()
{
    HRESULT hr = E_FAIL ;

    if(${TriaGram}UtlScriptManager::GetScriptManager().IsRecording())
        return SetFeatureDataViaAutomation() ;

	${intfName}_var sp${LateType} = _MyFeature ;
	CATAssert(NULL_var != sp${LateType} ) ;

<#list Attributes as attrib>
<#switch attrib.UI>
<#case "List">
<#case "BiList">

    CATLISTV(CATISpecObject_var)  list${attrib.name} ;
	_FrameStyle${attrib.name}._spLHSList->GetAsSpecObjectList(list${attrib.name}) ;

    <#if attrib.type == "tk_specobject">
    CATISpecObject_var  spSpec${attrib.name} = ( list${attrib.name}.Size() ) ? list${attrib.name}[1] : NULL_var ;
    sp${LateType}->Set${attrib.name}( spSpec${attrib.name} ) ;

    <#else>
    sp${LateType}->Set${attrib.name}(list${attrib.name} ) ;

    </#if>
<#break>
</#switch>
</#list>

<#list Attributes as attrib>
<#if  (attrib.UI?length > 0 ) >
<#switch attrib.type>

<#case "tk_boolean">
	CATBoolean   b${attrib.name} = FALSE  ;
	_pPanel->Get${attrib.name}( b${attrib.name} )   ;
	sp${LateType}->Set${attrib.name}( b${attrib.name} )   ;

<#break>
<#case "tk_integer">
	int   n${attrib.name} = 0  ;
	_pPanel->Get${attrib.name}( n${attrib.name} )   ;
	sp${LateType}->Set${attrib.name}( n${attrib.name} )   ;

<#break>
<#case "tk_double">
	double   d${attrib.name} = 0  ;
	_pPanel->Get${attrib.name}( d${attrib.name} )   ;
	sp${LateType}->Set${attrib.name}( d${attrib.name} )   ;

<#break>
<#case "tk_string">
	CATUnicodeString   str${attrib.name}   ;
	_pPanel->Get${attrib.name}( str${attrib.name} )   ;
	sp${LateType}->Set${attrib.name}( str${attrib.name} )   ;

<#break>
</#switch>
</#if>
</#list>

	return S_OK;
}

HRESULT ${className}::SetFeatureDataViaAutomation()
{
    HRESULT hr = E_FAIL ;

	${intfName}_var sp${LateType} = _MyFeature ;
	CATAssert(NULL_var != sp${LateType} ) ;

    CATIAReference* piReference = NULL;

	${IDLName}${LateType}_var spIA${LateType} = _MyFeature ;
	CATAssert(NULL_var != spIA${LateType} ) ;

<#list Attributes as attrib>
<#switch attrib.UI>
<#case "List">
<#case "BiList">

    CATLISTV(CATISpecObject_var)  list${attrib.name} ;
	_FrameStyle${attrib.name}._spLHSList->GetAsSpecObjectList(list${attrib.name}) ;

    <#if attrib.type == "tk_specobject">
    CATISpecObject_var  spSpec${attrib.name} = ( list${attrib.name}.Size() ) ? list${attrib.name}[1] : NULL_var ;

    hr = ::GetReferenceFromSpec(spSpec${attrib.name}, piReference);
    spIA${LateType}->put_${attrib.name}(piReference ) ;
    ${TriaGram}UtlReleasePtr(piReference) ;

    <#else>

    spIA${LateType}->Remove${attrib.name}( NULL) ;

    int n${attrib.name}  = _FrameStyle${attrib.name}._spLHSList->Size() ;
    for( int i =1 ; i <= n${attrib.name} ; i++ )
    {
		CATISpecObject_var spSpec = _FrameStyle${attrib.name}._spLHSList->GetSpec(i) ;
		if(NULL_var == spSpec)
			continue ;

        hr = ::GetReferenceFromSpec(spSpec, piReference);

        spIA${LateType}->Add${attrib.name}(piReference) ;

    	${TriaGram}UtlReleasePtr(piReference) ;
    }

    </#if>
<#break>
</#switch>
</#list>

<#list Attributes as attrib>
<#if  (attrib.UI?length > 0 ) >
<#switch attrib.type>

<#case "tk_boolean">
	CATBoolean   b${attrib.name} = FALSE  ;
	_pPanel->Get${attrib.name}( b${attrib.name} )   ;
	hr = spIA${LateType}->put_${attrib.name}( b${attrib.name} )   ;

<#break>
<#case "tk_integer">
	int   n${attrib.name} = 0  ;
	_pPanel->Get${attrib.name}( n${attrib.name} )   ;
	hr = spIA${LateType}->put_${attrib.name}( n${attrib.name} )   ;

<#break>
<#case "tk_double">
	double   d${attrib.name} = 0  ;
	_pPanel->Get${attrib.name}( d${attrib.name} )   ;
	hr = spIA${LateType}->put_${attrib.name}( d${attrib.name} )   ;

<#break>
<#case "tk_param_length">
<#case "tk_param_angle">
<#case "tk_param_real">
	double   d${attrib.name} = 0  ;
	sp${LateType}->Get${attrib.name}( d${attrib.name} )   ;
	hr = spIA${LateType}->put_${attrib.name}( d${attrib.name} )   ;

<#break>
<#case "tk_string">
	CATUnicodeString   str${attrib.name}   ;
	_pPanel->Get${attrib.name}( str${attrib.name} )   ;
	CATBSTR bstr${attrib.name} ;
	str${attrib.name} .ConvertToBSTR(&bstr${attrib.name}) ;

	hr = spIA${LateType}->put_${attrib.name}( bstr${attrib.name})   ;

<#break>
</#switch>
</#if>
</#list>

	return S_OK;
}

//-------------------------------------------------------------------------
// ${className} : CheckModel()
//-------------------------------------------------------------------------
HRESULT ${className}::CheckModel()
{
	HRESULT hr = S_OK ;

	${TriaGram}UtlErrorManager & errMgr = ${TriaGram}UtlErrorManager::GetErrorManager(TRUE) ;

    //${TriaGram}I${Prefix}ModelCheck_var spiModelCheckService = ::${TriaGram}UtlCreateContExtension(GetPart(), IID_${TriaGram}I${Prefix}ModelCheck) ;
    //CATAssert(NULL_var != spiModelCheckService)  ;

	//if( FALSE == spiModelCheckService->Check() )
	/*{
		${TriaGram}UtlErrDisplay::DisplayErrors("${baseName}Errors", "InvalidModel" ) ;
		return E_FAIL ;
	}

    if(errMgr.HasErrorsOfType(CATErrorTypeWarning))
    {
        CATListOfInt listErrType ;
        listErrType.Append(CATErrorTypeWarning) ;
        ${TriaGram}UtlErrDisplay::DisplayErrors("${baseName}Errors", "${baseName}Warning", CATDlgNfyWarning, listErrType ) ;
    }
	*/

    return hr ;
}




